extends Control

var reward_data: Dictionary

@onready var icon = $Panel/Icon
@onready var name_label = $Panel/Name
@onready var description_label = $Panel/Description
@onready var timer = $Timer

func setup(reward: Dictionary):
	reward_data = reward
	
	# 设置文本
	name_label.text = reward.get("name", "未知奖励")
	description_label.text = reward.get("description", "")
	
	# 设置图标（如果有）
	if reward.has("icon"):
		var icon_texture = load(reward["icon"])
		if icon_texture:
			icon.texture = icon_texture
	
	# 淡入动画
	modulate.a = 0.0
	var tween = create_tween()
	tween.tween_property(self, "modulate:a", 1.0, 0.3)
	
	# 设置自动消失
	timer.timeout.connect(_on_timer_timeout)
	timer.start()

func _on_timer_timeout():
	var tween = create_tween()
	tween.tween_property(self, "modulate:a", 0.0, 0.3)
	tween.tween_callback(queue_free)
